package com.swpu.cbg.cnshop.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;

import com.swpu.cbg.cnshop.bean.User;

/**
 * Created by chenboge on 16/2/20.
 */
public class BaseActivity extends AppCompatActivity{

    public void startActivity(Intent intent,boolean isNeedLogin){


        if(isNeedLogin){

            User user =MyApplication.getInstanse().getUser();
            if(user !=null){
                super.startActivity(intent);
            }
            else{
                MyApplication.getInstanse().putIntent(intent);
                Intent loginIntent = new Intent(this, LoginActivity.class);
                super.startActivity(loginIntent);
            }

        }
        else{
            super.startActivity(intent);
        }

    }
}
